package com.unibuy.smartdevice.tools;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.unibuy.smartdevice.ui.FontendActivity;

public class AppUtils {
    public static void resetApp(Context context) {
        Intent intent = new Intent(context, FontendActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

        PendingIntent pendingIntent = PendingIntent.getActivity(
                context, 0, intent, PendingIntent.FLAG_IMMUTABLE);

        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        alarmManager.setExact(AlarmManager.RTC, System.currentTimeMillis() + 500, pendingIntent);

        android.os.Process.killProcess(android.os.Process.myPid());
    }
}
